<template>
  <div>
    <el-upload class="upload-demo" drag action="/files/upLoad" :on-success="success" multiple>
      <i class="el-icon-upload"></i>
      <div class="el-upload__text">
        将文件拖到此处，或
        <em>点击上传</em>
      </div>
      <div class="el-upload__tip" slot="tip">只能上传jpg/png文件，且不超过500kb</div>
    </el-upload>
  </div>
</template>

<script>
import axios from "axios";
import { createNamespacedHelpers } from "vuex";
const {
  mapState: mapStateGoods,
  mapActions: mapActionsGoods
} = createNamespacedHelpers("goods");
export default {
  computed: {
    ...mapStateGoods(["listImages", "detailImages"])
  },
  methods: {
    success(response, file, fileList) {
      var count=1
      let path = response.file[0].path.substr(6);
      if(count==1){
        this.listImages = path;
      }
      this.detailImages.push(path);
      count++
    }
  }
};
</script>

<style>
.upload-demo {
  width: 100%;
}
</style>